<template>
  <div class="repay-detail">
    <fieldset>
      <legend style="margin-left:-12px;" class="field-title">基本信息</legend>
      <config-form :initData="repayOverdueCustomerInfo" :span="6" :options="BACIS_FORM" />
    </fieldset>
    <fieldset>
      <legend style="margin-left:-12px;" class="field-title">还款信息</legend>
      <config-form :initData="repayForm" :span="6" :options="REPAY_FORM" />
    </fieldset>
    <fieldset>
      <legend style="margin-left:-12px;" class="field-title">借款信息</legend>
      <config-form :initData="repayForm" :span="6" :options="LOAN_FORM" />
    </fieldset>
  </div>
</template>

<script>
import api from '../api'
import { CONSTANT_OBJ } from '@/utils/constant'
import { BACIS_FORM, REPAY_FORM, LOAN_FORM } from '../js/contant.js'
export default {
  props: { overdueId: String },
  data () {
    return {
      BACIS_FORM,
      REPAY_FORM,
      LOAN_FORM,
      repayForm: {},
      repayOverdueCustomerInfo: {}
    }
  },
  mounted () {
    this.getData()
  },
  methods: {
    // 获取数据
    getData () {
      api.getQueryByIdRepayData(this.overdueId).then(res => {
        const { responseCode, data } = res
        if (responseCode === CONSTANT_OBJ.RES_SUCCESS) {
          let result = { ...data }
          this.repayForm = result || {}
          this.repayOverdueCustomerInfo = result.repayOverdueCustomerInfo || {}
          this.repayOverdueCustomerInfo.addressList.forEach(item => {
            if (item.addressType === 'C') {
              this.repayOverdueCustomerInfo.organAdrr = `${item.province}${item.city}${item.town}${item.street}`
            } else if (item.addressType === 'H') {
              this.repayOverdueCustomerInfo.homeAdrr = `${item.province}${item.city}${item.town}${item.street}`
            }
          })
        }
      })
    }
  }
}
</script>
<style lang="less" scoped>
@import "../../../assets/css/global.less";
.repay-detail {
  fieldset {
    padding: 0 10px;
    margin-bottom: 10px;
    border-color: @theme-color;
  }
  .field-title {
    color: @theme-color;
  }
  .el-form-item--mini.el-form-item.isEdit {
    margin-bottom: 5px;
  }
}
</style>
